home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / super_su.swf / scripts / DefineSprite_84_mc_tiburon / frame_1 / DoAction.as
Encoding:
Text File  |  2007-04-19  |  1.4 KB  |  63 lines

  1. function mKill()
  2. {
  3.    this._parent.mKillObject(this);
  4. }
  5. function mPhysics(interval)
  6. {
  7.    var newPosX = this.intPosX + this.intVelX * interval;
  8.    var newPosY = this.intPosY + this.intVelY * interval;
  9.    this.intPosX = newPosX;
  10.    this.intPosY = newPosY;
  11. }
  12. function mStepFrame(interval)
  13. {
  14.    this.mPhysics(interval);
  15.    if(this.frmcnt == 0)
  16.    {
  17.       this.intPosYcentral = this.intPosY;
  18.    }
  19.    var angle = this.frmcnt * 2 * 3.141592653589793 / 36;
  20.    this.intPosY = this.intPosYcentral + Math.sin(angle) * 30;
  21.    this.frmcnt += interval;
  22.    if(this.intRadius < 1)
  23.    {
  24.       this.intRadius = 20;
  25.    }
  26.    if(this.strID.length < 1)
  27.    {
  28.       this.strID = "obst";
  29.    }
  30.    var oChar = this._parent.oChar;
  31.    var dX = Math.abs(oChar.intPosX - this.intPosX);
  32.    if(dX < 200)
  33.    {
  34.       var arrPnts = oChar.mGetPoints();
  35.       var hit = false;
  36.       var i = 0;
  37.       while(i < arrPnts.length)
  38.       {
  39.          var dX = this.intPosX - arrPnts[i].x;
  40.          var dY = this.intPosY - arrPnts[i].y;
  41.          var dAbs = Math.abs(Math.sqrt(dX * dX + dY * dY));
  42.          if(dAbs < this.intRadius)
  43.          {
  44.             var hit = true;
  45.          }
  46.          i++;
  47.       }
  48.       if(hit)
  49.       {
  50.          this.play();
  51.          oChar.mCollide(this.strID);
  52.       }
  53.    }
  54.    if(oChar.intPosX - this.intPosX > 500)
  55.    {
  56.       this.mKill();
  57.    }
  58. }
  59. this.intRadius = 40;
  60. this.strID = "bomb";
  61. this.frmcnt = 0;
  62. stop();
  63.